/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */#ifndef MOZILLA_GFX_IMAGECLIENT_H#define MOZILLA_GFX_IMAGECLIENT_H#include<stdint.h> // for uint32_t, uint64_t#include<sys/types.h> // for int32_t#include"mozilla/Attributes.h" // for override#include"mozilla/RefPtr.h" // for RefPtr, already_AddRefed#include"mozilla/gfx/Types.h" // for SurfaceFormat#include"mozilla/layers/CompositableClient.h" // for CompositableClient#include"mozilla/layers/CompositorTypes.h" // for CompositableType, etc#include"mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor#include"mozilla/layers/TextureClient.h" // for TextureClient, etc#include"mozilla/mozalloc.h" // for operator delete#include"nsCOMPtr.h" // for already_AddRefed#include"nsRect.h" // for mozilla::gfx::IntRectnamespacemozilla{namespacelayers{classClientLayer;classCompositableForwarder;classImage;classImageContainer;classShadowableLayer;classImageClientSingle;/** * Image clients are used by basic image layers on the content thread, they * always match with an ImageHost on the compositor thread. See * CompositableClient.h for information on connecting clients to hosts. */classImageClient:publicCompositableClient{public:/** * Creates, configures, and returns a new image client. If necessary, a * message will be sent to the compositor to create a corresponding image * host. */staticalready_AddRefed<ImageClient>CreateImageClient(CompositableTypeaImageHostType,CompositableForwarder*aFwd,TextureFlagsaFlags);virtual~ImageClient(){}/** * Update this ImageClient from aContainer in aLayer * returns false if this is the wrong kind of ImageClient for aContainer. * Note that returning true does not necessarily imply success */virtualboolUpdateImage(ImageContainer*aContainer,uint32_taContentFlags)=0;voidSetLayer(ClientLayer*aLayer){mLayer=aLayer;}ClientLayer*GetLayer()const{returnmLayer;}/** * asynchronously remove all the textures used by the image client. * */virtualvoidFlushAllImages(){}virtualvoidRemoveTexture(TextureClient*aTexture)override;virtualImageClientSingle*AsImageClientSingle(){returnnullptr;}staticalready_AddRefed<TextureClient>CreateTextureClientForImage(Image*aImage,KnowsCompositor*aForwarder);uint32_tGetLastUpdateGenerationCounter(){returnmLastUpdateGenerationCounter;}protected:ImageClient(CompositableForwarder*aFwd,TextureFlagsaFlags,CompositableTypeaType);ClientLayer*mLayer;CompositableTypemType;uint32_tmLastUpdateGenerationCounter;};/** * An image client which uses a single texture client. */classImageClientSingle:publicImageClient{public:ImageClientSingle(CompositableForwarder*aFwd,TextureFlagsaFlags,CompositableTypeaType);virtualboolUpdateImage(ImageContainer*aContainer,uint32_taContentFlags)override;virtualvoidOnDetach()override;virtualboolAddTextureClient(TextureClient*aTexture)override;virtualTextureInfoGetTextureInfo()constoverride;virtualvoidFlushAllImages()override;ImageClientSingle*AsImageClientSingle()override{returnthis;}boolIsEmpty(){returnmBuffers.IsEmpty();}protected:structBuffer{RefPtr<TextureClient>mTextureClient;int32_tmImageSerial;};nsTArray<Buffer>mBuffers;};/** * Image class to be used for async image uploads using the image bridge * protocol. * We store the ImageBridge id in the TextureClientIdentifier. */classImageClientBridge:publicImageClient{public:ImageClientBridge(CompositableForwarder*aFwd,TextureFlagsaFlags);virtualboolUpdateImage(ImageContainer*aContainer,uint32_taContentFlags)override;virtualboolConnect(ImageContainer*aImageContainer)override{returnfalse;}virtualTextureInfoGetTextureInfo()constoverride{returnTextureInfo(mType);}protected:CompositableHandlemAsyncContainerHandle;};}// namespace layers}// namespace mozilla#endif